package com.ibeeking.gmc.global.g.rest.controller.v1;

import com.ibeeking.found.common.annotation.LoginUser;
import com.ibeeking.found.common.entity.CurrentUser;
import com.ibeeking.gmc.global.service.common.param.TenantEnterpriseInfoParam;
import com.ibeeking.gmc.global.service.common.query.TenantEnterpriseInfoPageQuery;
import com.ibeeking.gmc.global.service.common.vo.TenantEnterpriseInfoVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName enterpriseInfoController控制器
 * @Description
 * @Author ibeeking
 * @Date 2020-12-24 13:45
 **/
@RestController
@RequestMapping("/g/enterpriseinfo/v1")
public class TenantEnterpriseInfoController {

    @Resource
    private com.ibeeking.gmc.global.g.rest.service.ITenantEnterpriseInfoService ITenantEnterpriseInfoService;


    @Log(logType = OperateLogTypeEnum.QUERY, describe = "")
    @PostMapping(value = "/pageList")
    public Page<TenantEnterpriseInfoVO> pageList(@RequestBody TenantEnterpriseInfoPageQuery tenantEnterpriseInfoPageQuery) {
        return ITenantEnterpriseInfoService.pageList(tenantEnterpriseInfoPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "新增企业信息")
    @PostMapping(value = "/add")
    public Boolean add(@LoginUser CurrentUser currentUser,@RequestBody @Validated(BaseValidationGroup.Insert.class) TenantEnterpriseInfoParam tenantEnterpriseInfoParam) {
        tenantEnterpriseInfoParam.setModifyBy(currentUser.getId()).setCreateBy(currentUser.getId());
        return ITenantEnterpriseInfoService.add(tenantEnterpriseInfoParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改企业信息")
    @PostMapping(value = "/modify")
    public Boolean modify(@LoginUser CurrentUser currentUser, @RequestBody @Validated(BaseValidationGroup.Update.class) TenantEnterpriseInfoParam tenantEnterpriseInfoParam) {
        tenantEnterpriseInfoParam.setModifyBy(currentUser.getId());
        return ITenantEnterpriseInfoService.modify(tenantEnterpriseInfoParam);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询企业信息详情")
    @PostMapping(value = "/view/{id}")
    public TenantEnterpriseInfoVO view(@PathVariable("id") Long id) {
        return ITenantEnterpriseInfoService.view(id);
    }


    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除企业信息")
    @PostMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return ITenantEnterpriseInfoService.del(id);
    }
}